package com.nmf.site.modules.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.nmf.dao.gen.BizSysRoleMapper;
import com.nmf.dao.gen.BizSysUserRoleMapper;
import com.nmf.dao.gen.bean.BizSysRole;
import com.nmf.dao.gen.bean.BizSysUserRoleExample;
import com.nmf.dao.gen.bean.BizSysUserRoleKey;

@Component
public class RoleService {
	@Autowired
	BizSysRoleMapper bizSysRoleMapper;
	@Autowired
	BizSysUserRoleMapper bizSysUserRoleMapper;
	public BizSysRole queryRole(String userId) {
		BizSysUserRoleExample bizSysUserRoleExample = new BizSysUserRoleExample();
		bizSysUserRoleExample.createCriteria().andUserIdEqualTo(userId);
		List<BizSysUserRoleKey> rklist = bizSysUserRoleMapper.selectByExample(bizSysUserRoleExample);
		
		return bizSysRoleMapper.selectByPrimaryKey(rklist.get(0).getRoleId());
	}
	
	public String queryRoleEnname(String userId) {
		return queryRole(userId).getEnname();
	}
}
